/**
 * This file shows how to create a custom component and register that within an Angular application.
 *
 * Get the base component class by referencing Formio.Components.components map.
 */
import {Components} from 'formiojs';

const FieldComponent = (Components as any).components.field;
/**
 * Here we will derive from the base component which all Form.io form components derive from.
 *
 * @param component
 * @param options
 * @param data
 * @constructor
 */
class SelectUser extends (FieldComponent as any) {
    public checks: Array<Array<any>>;
    constructor(component: any, options: any, data: any) {
        super(component, options, data);
        this.checks = [];
    }

    public static editForm = {};
    static schema() {
        return FieldComponent.schema({
            type: 'selectuser',
            numRows: 1,
            numCols: 1
        });
    }


    static builderInfo = {
        title: 'SelectUser',
        group: 'basic',
        icon: 'fa fa-table',
        weight: 70,
        documentation: 'http://help.form.io/userguide/#table',
        schema: SelectUser.schema()
    }


    public render(children: any) {
        return super.render(children);
    }

    /**
     * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific
     * elements to attach functionality to.
     *
     * @param element
     * @returns {Promise}
     */
    attach(element: any) {
        // Allow basic component functionality to attach like field logic and tooltips.
        return super.attach(element);
    }

    /**
     * Get the value of the component from the dom elements.
     *
     * @returns {Array}
     */
    getValue() {
        return '111';
    }

    /**
     * Set the value of the component into the dom elements.
     *
     * @param value
     * @returns {boolean}
     */
    setValue(value: any) {
        console.log(value)
    }
}

SelectUser.editForm = (...args: any) => {
    return FieldComponent.editForm(...args);
};

Components.addComponent('selectuser', SelectUser);
